﻿#include<iostream>
using namespace std;

const int N = 100010;
int n, m, a[N], b[N];
int main() 
{
	//用于加快执行效率
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	
	cin >> n >> m;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < m; i++)cin >> b[i];
	
	int i = 0, j = 0;
	while (i < n && j < m) 
	{
		if (a[i] == b[j])
			i++;
		j++;
	}
	if (i == n)puts("Yes");
	else puts("No");
	//两者均可
	//cout << (i == n ? "Yes" : "No") << endl;
	system("pause");
	return 0;
};